unit ImgBtnWidget;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, Vcl.Imaging.pngimage, Vcl.ExtCtrls;

type
  TfrImgBtn = class(TFrame)
    image: TImage;
    Button: TLabel;
    procedure imageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure imageMouseEnter(Sender: TObject);
    procedure imageMouseLeave(Sender: TObject);
    procedure imageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;

implementation

uses
  MsgWidget;

{$R *.dfm}

constructor TfrImgBtn.Create(AOwner: TComponent);
begin
  inherited;
  image.Picture.LoadFromFile(imageFile('button1'));
end;

procedure TfrImgBtn.imageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  image.Picture.LoadFromFile(imageFile('button3'));
end;

procedure TfrImgBtn.imageMouseEnter(Sender: TObject);
begin
  image.Picture.LoadFromFile(imageFile('button2'));
end;

procedure TfrImgBtn.imageMouseLeave(Sender: TObject);
begin
  image.Picture.LoadFromFile(imageFile('button1'));
end;

procedure TfrImgBtn.imageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  image.Picture.LoadFromFile(imageFile('button2'));
end;

end.

